<%@ page import="com.touzi.constants.DbCons" %>
<%@ page import="org.apache.ibatis.session.SqlSessionFactory" %>
<%@ page import="com.touzi.mapper.UserMapper" %>
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="com.touzi.beans.dbs.users.User" %>
<%@ page import="com.touzi.mapper.ChanpinMapper" %>
<%@ page import="com.touzi.beans.dbs.chanpin.Chanpin" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%--
修改已有产品
--%>
<%

    SqlSession sqlSession = ((SqlSessionFactory) application.getAttribute(DbCons.DB_FACTORY)).openSession();
    ChanpinMapper chanpinMapper = sqlSession.getMapper(ChanpinMapper.class);

    try {
        String chanpinid = request.getParameter("chanpinid");
        Chanpin chanpin = chanpinMapper.findById(Integer.parseInt(chanpinid));

        request.setAttribute("chanpin", chanpin);
    } finally {
        sqlSession.close();
    }

%>

<!DOCTYPE html>
<html lang="en">
<head>
    <title>修改产品</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/css/bootstrap.css">
    <script src="/js/bootstrap.js"></script>
    <script src="/js/jquery-3.3.1.js"></script>
    <style type="text/css">
        .content {
            padding: 16px;
            width: 400px;
            margin: auto;
        }
    </style>
</head>
<body>
<div class="content">
    <form class="form-horizontal" role="form" method="post" action="/admdesk">
        <%--<form class="form-horizontal" role="form" method="get">--%>
        <input name="method" value="xiugaichanpin" style="display: none">
        <input name="id" value="${chanpin.id}" style="display: none">
        <%--biaoti | jiage | xiangou | fenhongcishu | fenhongzhouqi | shengyu | fenhong | paixu | keyong--%>
        <div class="form-group">
            <label for="disabledInput" class="col-sm-2 control-label">
                产品标题
            </label>
            <div class="col-sm-10">
                <input name="biaoti" value="${chanpin.biaoti}" class="form-control" id="disabledInput" type="text"
                       placeholder="">
            </div>
        </div>

        <div class="form-group">
            <label for="firstname" class="col-sm-2 control-label">产品价格</label>
            <div class="col-sm-10">
                <input name="jiage" value="${chanpin.jiage}" type="number" class="form-control" id="firstname"
                       placeholder="">
            </div>
        </div>


        <div class="form-group">
            <label for="firstname3" class="col-sm-2 control-label">库存</label>
            <div class="col-sm-10">
                <input name="shengyu" value="${chanpin.shengyu}" type="number" class="form-control" id="firstname3"
                       placeholder="">
            </div>
        </div>

        <div class="form-group">
            <label for="firstname2" class="col-sm-2 control-label">限购(未实现)</label>
            <div class="col-sm-10">
                <input name="xiangou" value="${chanpin.xiangou}" type="number" class="form-control" id="firstname2"
                       placeholder="">
            </div>
        </div>

        <div class="form-group">
            <label for="lastname" class="col-sm-2 control-label">每次分红</label>
            <div class="col-sm-10">
                <input name="fenhong" value="${chanpin.fenhong}" type="number" class="form-control" id="lastname"
                       placeholder="">
            </div>
        </div>

        <div class="form-group">
            <label for="zhifubao" class="col-sm-2 control-label">分红次数</label>
            <div class="col-sm-10">
                <input name="fenhongcishu" value="${chanpin.fenhongcishu}" type="number" class="form-control"
                       id="zhifubao"
                       placeholder="">
            </div>
        </div>

        <div class="form-group">
            <label for="zhenming" class="col-sm-2 control-label">分红周期(小时)</label>
            <div class="col-sm-10">
                <input name="fenhongzhouqi" value="${chanpin.fenhongzhouqi}" type="number" class="form-control"
                       id="zhenming"
                       placeholder="">
                <%--<select name="fenhongzhouqi" class="form-control" id="zhenming">--%>
                    <%--<option selected value="1">1</option>--%>
                    <%--<option value="2">2</option>--%>
                    <%--<option value="3">3</option>--%>
                    <%--<option value="4">4</option>--%>
                    <%--<option value="5">5</option>--%>
                    <%--<option value="6">6</option>--%>
                    <%--<option value="12">12</option>--%>
                    <%--<option value="24">24</option>--%>
                    <%--<option value="48">48</option>--%>
                <%--</select>--%>
            </div>
        </div>

        <div class="form-group">
            <label for="keyong" class="col-sm-2 control-label">排序</label>
            <div class="col-sm-10">
                <input name="paixu" value="${chanpin.paixu}" type="number" class="form-control" id="keyong"
                       placeholder="">
            </div>
        </div>

        <div class="form-group">
            <label for="keyong1" class="col-sm-2 control-label">是否可用</label>
            <div class="col-sm-10">
                <select name="keyong" class="form-control" id="keyong1">
                    <option selected value="yes">yes</option>
                    <option value="no">no</option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <br>
                <button type="submit" class="btn btn-default">提交</button>
            </div>
        </div>
    </form>

</div>
</body>
</html>
